
public class GameBoard {
	public int xDimension;
	public int yDimension;
	public GamePiece[][] board;
	
	
	public GameBoard() {
		super();
		board=new GamePiece[xDimension][yDimension];
	}
	
	public GameBoard(int dimension, int dimension2) {
		super();
		xDimension = dimension;
		yDimension = dimension2;
		board=new GamePiece[xDimension][yDimension];
	}
	
	public synchronized int makeMove(GamePiece gp, int x){		
		
		int yPosition=-1;
		for(int y = 0; y < yDimension; y++){			
			if(board[x][y]==null)
			{
				yPosition = y;
				break;
			}
		}
		
		if(yPosition >= 0){
			board[x][yPosition] = gp;
			gp.y = yPosition;
			return yPosition;
		}else{
			return -1;
		}
		
	}
	
	public void undoMove(){
		
	}
	
	
	public synchronized void reset(){
		board = new GamePiece[xDimension][yDimension];
	}
	
	public void destroy(){
		board = new GamePiece[xDimension][yDimension];
	}
	
	public void saveBoard(){
		
	}
	
	public void draw(){
		
	}
	
	public GamePiece getPieceAt(int x, int y){
		if(x<0||y<0||x>=xDimension||y>=yDimension)
			return null;
		return board[x][y];		
	}
	
	public synchronized void setPieceAt(int x, int y, GamePiece gp){
		board[x][y] = gp;		
	}
	
	public int getXDimension() {
		return xDimension;
	}
	public synchronized void setXDimension(int dimension) {
		xDimension = dimension;
	}
	public int getYDimension() {
		return yDimension;
	}
	public synchronized void setYDimension(int dimension) {
		yDimension = dimension;
	}

}
